package com.atguigu.gulimall.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class MyThreadConfig {

    /**
     * 自定义线程池的参数
     * @param threadPoolProperties 绑定的配置文件
     * @return
     */
    @Bean
    public ThreadPoolExecutor myTheradPoolExecutor(MyThreadPoolProperties threadPoolProperties){

       return new ThreadPoolExecutor(threadPoolProperties.getCorePoolSize(),
               threadPoolProperties.getMaximumPoolSize(),
               threadPoolProperties.getKeepAliveTime(),
                TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(2000),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy());

    }


}
